﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tb_PaymentDAL : SqlDataProvider
	{

		#region[tb_Payment_GetbyAll]
		public DataTable tb_Payment_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Payment_GetbyId]
		public DataTable tb_Payment_GetById(tb_PaymentInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Payment_GetbyTop]
		public DataTable tb_Payment_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Payment_GetbyServiceId]
		public DataTable tb_Payment_GetByServiceId(string ServiceId)
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_GetByServiceId", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@ServiceId", ServiceId));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Payment_GetbyUserId]
		public DataTable tb_Payment_GetByUserId(string UserId)
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_GetByUserId", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@UserId", UserId));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Payment_Insert]
		public void tb_Payment_Insert(tb_PaymentInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@UserId", Data.UserId));
				cmd.Parameters.Add(new SqlParameter("@ServiceId", Data.ServiceId));
				cmd.Parameters.Add(new SqlParameter("@DateTime", Data.DateTime));
				cmd.Parameters.Add(new SqlParameter("@Amount", Data.Amount));
				cmd.Parameters.Add(new SqlParameter("@Phone", Data.Phone));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_Payment_Update]
		public void tb_Payment_Update(tb_PaymentInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				cmd.Parameters.Add(new SqlParameter("@UserId", Data.UserId));
				cmd.Parameters.Add(new SqlParameter("@ServiceId", Data.ServiceId));
				cmd.Parameters.Add(new SqlParameter("@DateTime", Data.DateTime));
				cmd.Parameters.Add(new SqlParameter("@Amount", Data.Amount));
				cmd.Parameters.Add(new SqlParameter("@Phone", Data.Phone));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_Payment_Delete]
		public void tb_Payment_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Payment_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
        #region[tb_PaymentService_GetByUName]
        public DataTable tb_PaymentService_GetByUName(tb_PaymentInfo Data)
        {
            using (var cmd = new SqlCommand("sp_viewBillByUName", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Username", Data.UserName));
                var da = new SqlDataAdapter(cmd);
                var dt = new DataTable();
                da.Fill(dt);
                return dt;
            }
        }
        #endregion
    }
}